<?php

  // rme added
  $DistrictUid = $_SESSION["DISTRICT"];
  // rme end
  
  try {  	

  $G_MAIN_MENU = 'processmaker';
  $G_SUB_MENU = 'hr/menuhrDistricts';
  $G_ID_MENU_SELECTED = 'ID_HR_DIS';
  $G_ID_SUB_MENU_SELECTED = 'ID_HR_LOCATIONS';

  $G_PUBLISH = new Publisher;

  require_once ( PATH_PLUGINS . 'hr' . PATH_SEP . 'class.hr.php');
  $pluginObj = new hrClass ();

  require_once ( "classes/model/HrLocations.php" );

  // rme added
  include( PATH_PLUGINS . 'hr' . PATH_SEP . 'submenuhrDistricts.inc.php' );

  require_once ( "classes/model/HrDistricts.php" );
  $tr = HrDistrictsPeer::retrieveByPK( $DistrictUid  );
  
  if ( ( is_object ( $tr ) &&  get_class ($tr) == 'HrDistricts' ) )
    $fields00['DISTRICTNAME'] = $tr->getDistrictname();
  else
    $fields00 = array();

  $G_PUBLISH->AddContent('xmlform', 'xmlform', 'hr/hrDistrictsView', '', $fields00, '' );
  // rme end

  $Criteria = new Criteria('workflow');
  $Criteria->clearSelectColumns ( );
  
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATION_UID );
  $Criteria->addSelectColumn (  HrLocationsPeer::DISTRICT_ID );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONSTATE_ID );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONNAME );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONADDRESS1 );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONADDRESS2 );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONSITE );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONZIPCODE );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONPHONE );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONFAX );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONCODE );
  $Criteria->addSelectColumn (  HrLocationsPeer::LOCATIONCOMMENTS );
  $Criteria->addSelectColumn (  HrLocationsPeer::IRN );
  $Criteria->addSelectColumn (  HrLocationsPeer::MAINDISTRICTLOCATION );

  $Criteria->add (  hrLocationsPeer::LOCATION_UID, "xx" , CRITERIA::NOT_EQUAL );
  
  // rme added
  $Criteria->add (  hrLocationsPeer::DISTRICT_ID, $DistrictUid , CRITERIA::EQUAL );
  $fields["DISTRICT"] = $DistrictUid;
  
  $G_PUBLISH->AddContent('propeltable', 'paged-table', 'hr/hrLocationsList', $Criteria , $fields,'', '../../gulliver/propelTableAjax');
  // rme end

  G::RenderPage('publish', 'blank');

  }
  catch ( Exception $e ) {
    $G_PUBLISH = new Publisher;
    $aMessage['MESSAGE'] = $e->getMessage();
    $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
    G::RenderPage( 'publish', 'blank' );
  }      
